<template>
    <div id="pindao-bottom">
        <div class="pindao-bottom-box" v-for="(v) in this.$store.state.seach.huati" v-bind:key="v.id">
            <div class="top">
                <img :src="v.img" alt="">
                <p class="p">
                    <span class="title">{{v.tit}}</span>
                    <span class="tit">近一周讨论  <em>{{v.num}}</em></span>
                </p>
                <p class="act">＋&nbsp;&nbsp;关注</p>
            </div>
            <div class="middle">
                <h2>{{v.title}}</h2>
                <p>{{v.text}}</p>
            </div>
            <div class="bottom">
                <span class="Yes" v-if="v.read!==''"><i>{{v.read}}</i>万阅读</span>
                <span class="text">
                    <em>{{v.Yes}}</em>赞同·
                    <em v-if="read===''"><em>{{v.option}}</em>评论·</em>
                    <em>{{v.time}}</em>
                </span>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        name: "top",
        data(){
            return {
                read:"few",
                read1:""
            }
        },
        created () {
            //在页面加载时读取localStorage里的状态信息
            if (localStorage.getItem("data") ) {
                //replaceState替换数据 Object.assign合并对象
                this.$store.replaceState(Object.assign({}, this.$store.state,JSON.parse(localStorage.getItem("data"))))
            }
            //在页面刷新时将vuex里的信息保存到localStorage里
            window.addEventListener("beforeunload",()=>{
                localStorage.setItem("data",JSON.stringify(this.$store.state))
            })
        },
    }
</script>

<style lang="scss">
    #pindao-bottom{

        .pindao-bottom-box{
            width: 3.44rem;
            padding: 0.19rem 0.12rem 0.16rem 0.1rem;
            background-color: #ffffff;
            margin-top: 0.12rem;
            border-radius: 0.06rem;

            .top{
                height: 0.36rem;
                display: flex;
                justify-content: flex-start;
                align-items: center;
                position: relative;
                margin-bottom: 0.12rem;

                img{
                    width: 0.34rem;
                    margin-right: 0.07rem;
                }

                .p{
                    display: flex;
                    flex-direction: column;
                    justify-content: flex-start;

                    .title{
                        font-size: 0.14rem;
                        color: #000000;
                    }
                    .tit{
                        font-size: 0.12rem;
                        color: #616161;
                        line-height: 0.16rem;

                        em{
                            font-style: normal;
                        }
                    }
                }

                .act{
                    width: 0.68rem;
                    height: 0.34rem;
                    background-color: #f6f6f6;
                    color: #54acfc;
                    text-align: center;
                    line-height: 0.34rem;
                    font-weight: bold;
                    position: absolute;
                    right: 0;
                }

            }

            .middle{

                h2{
                    font-size: 0.16rem;
                    color: #000000;
                    margin-bottom: 0.04rem;
                }

                p{
                    font-size: 0.14rem;
                    color: #2c2c2c;
                }
            }

            .bottom{
                font-size: 0.14rem;
                color: #080808;
                display: flex;
                justify-content: flex-start;
                align-items: center;

                .Yes{
                    display: block;
                    width: 0.83rem;
                    height: 0.27rem;
                    color: #f85b00;
                    font-weight: bold;
                    background-color: #fff7ed;
                    text-align: center;
                    line-height: 0.27rem;
                    margin-right: 0.1rem;


                    i{
                        font-style: normal;
                    }
                }

                .text{

                    font-size: 0.14rem;
                    color: #000;

                    em{
                        font-style: normal;
                    }
                }
            }
        }
    }
</style>